package com.utc.cards.model.player;

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

import com.utc.cards.model.deck.Deck;

public abstract class AbstractPlayer implements IPlayer
{
    private String _name;
    private int _color;

    private Map<String, Deck> _hands = new HashMap<String, Deck>();

    public AbstractPlayer(String name)
    {
        _name = name;
        _color = android.graphics.Color.DKGRAY;
        _hands.put(MAIN_HAND, new Deck());
    }

    @Override
    public String getName()
    {
        return _name;
    }

    @Override
    public Deck getHand()
    {
        return _hands.get(MAIN_HAND);
    }

    @Override
    public Deck getHand(String handType)
    {
        return _hands.get(handType);
    }

    @Override
    public Map<String, Deck> getHands()
    {
        return _hands;
    }

    @Override
    public void setHand(Deck hand)
    {
        this._hands.put(MAIN_HAND, hand);
    }

    @Override
    public void setHands(Map<String, Deck> hands)
    {
        this._hands.clear();
        for (Entry<String, Deck> entry : hands.entrySet())
        {
            _hands.put(entry.getKey(), entry.getValue());
        }
    }

    @Override
    public void setHand(Deck hand, String handType)
    {
        this._hands.put(handType, hand);
    }

    @Override
    public int getDisplayColor()
    {
        return _color;
    }

    @Override
    public void setDisplayColor(int c)
    {
        _color = c;
    }

    public String toString()
    {
        return _name;
    }

}
